<?php

namespace App\Models\Workflow;

use App\Models\BaseModel;
use App\Models\Traits\KfSoftDeletes;
use App\Models\Traits\KfUid;
use Illuminate\Database\Eloquent\Relations\HasMany;

class WorkflowV2TemplateNodeModel extends BaseModel
{
    use KfUid;
    use KfSoftDeletes;

    protected $table = 'workflow_v2_template_nodes';

    protected $fillable = [
        'workflowTemplateId',
        'workflowTemplateNodeId',
        'pId',
        'nextId',
        'prevId',
        'cruiseTemplateId',
        'name',
        'businessType',
        'nodeType',
        'handlerType',
        'handlerUids',
        'condition',
        'ccInfo',
        'isDeleted'
    ];

    public function childrenRel(): HasMany
    {
        return $this->hasMany(WorkflowV2TemplateNodeModel::class, 'pId', 'id');
    }

    public function handlersRel(): HasMany
    {
        return $this->hasMany(WorkflowV2OrderNodeHandlerModel::class, 'workflowTemplateNodeId', 'id');
    }
}
